import React, {memo, useCallback} from 'react';
import {Pagination} from 'antd';
import proptypes from "prop-types";
import {AdminPaginationWrapper} from "./style";

function AdminPagination(props) {
  const {total, defaultPageSize, current, handleChange} = props;

  const dealChange = useCallback((page, pageSize) => {
    handleChange(page, pageSize);
  }, [handleChange])

  return (
    <AdminPaginationWrapper>
      <Pagination
        current={current}
        total={total}
        defaultPageSize={defaultPageSize}
        hideOnSinglePage={true}
        onChange={dealChange}
      />
    </AdminPaginationWrapper>
  )
}

AdminPagination.propTypes = {
  total: proptypes.number,
  current: proptypes.number,
  defaultPageSize: proptypes.number,
  handleChange: proptypes.func
}

export default memo(AdminPagination)
